﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Amazon.PAAPI
{
	using System.ServiceModel;

	class Program
	{
		static void Main(string[] args)
		{
			// Instantiate Amazon ProductAdvertisingAPI client
			AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();
			
			// prepare an ItemSearch request
			ItemSearchRequest request = new ItemSearchRequest();
			request.SearchIndex = "Books";
			request.Title = "Tyler";
			request.ResponseGroup = new string[] { "Small" };

			ItemSearch itemSearch = new ItemSearch();
			itemSearch.Request = new ItemSearchRequest[] { request };
			itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
			itemSearch.AssociateTag = "ReplaceWithYourValue";

			// send the ItemSearch request
			ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

			// write out the results from the ItemSearch request
			foreach (var item in response.Items[0].Item)
			{
				Console.WriteLine(item.ItemAttributes.Title);
				Console.WriteLine(item.ItemAttributes.Author[0]);
				Console.Write(Environment.NewLine);
			}
			Console.WriteLine(Environment.NewLine + "done...enter any key to continue>");
			Console.ReadLine();

		}
	}

	class OtherClass
	{
		public OtherClass()
		{
			object prog = new Program();
		}
	}
}
